package fivecardstudd;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;

public class HandTest {



	@Test
	public void testRoyalFlush() {
		Hand hand = new Hand();
        hand.addCard(new Card(Card.CardRankEnum.ACE,Card.CardSuitEnum.HEARTS));
        hand.addCard(new Card(Card.CardRankEnum.KING,Card.CardSuitEnum.HEARTS));
        hand.addCard(new Card(Card.CardRankEnum.QUEEN,Card.CardSuitEnum.HEARTS));
        hand.addCard(new Card(Card.CardRankEnum.JACK,Card.CardSuitEnum.HEARTS));
        hand.addCard(new Card(Card.CardRankEnum.TEN,Card.CardSuitEnum.HEARTS));
        int [] array ={10,14,13,12,11,10};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	@Test
	public void testStraightFlush() {
		 Hand hand = new Hand();
         hand.addCard(new Card(Card.CardRankEnum.QUEEN,Card.CardSuitEnum.HEARTS));
         hand.addCard(new Card(Card.CardRankEnum.JACK,Card.CardSuitEnum.HEARTS));
         hand.addCard(new Card(Card.CardRankEnum.NINE,Card.CardSuitEnum.HEARTS));
         hand.addCard(new Card(Card.CardRankEnum.TEN,Card.CardSuitEnum.HEARTS));
         hand.addCard(new Card(Card.CardRankEnum.EIGHT,Card.CardSuitEnum.HEARTS));
        int [] array ={9,12,11,10,9,8};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testQuadruple() {
		 Hand hand = new Hand();
         hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.SPADES));
         hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.HEARTS));
         hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.DIAMONDS));
         hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.CLUBS));
         hand.addCard(new Card(Card.CardRankEnum.ACE,Card.CardSuitEnum.HEARTS));
        int [] array ={8,5,14,0,0,0};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testFullHouse() {
		  Hand hand = new Hand();
          hand.addCard(new Card(Card.CardRankEnum.SEVEN,Card.CardSuitEnum.SPADES));
          hand.addCard(new Card(Card.CardRankEnum.THREE,Card.CardSuitEnum.HEARTS));
          hand.addCard(new Card(Card.CardRankEnum.THREE,Card.CardSuitEnum.DIAMONDS));
          hand.addCard(new Card(Card.CardRankEnum.SEVEN,Card.CardSuitEnum.CLUBS));
          hand.addCard(new Card(Card.CardRankEnum.SEVEN,Card.CardSuitEnum.HEARTS));
        int [] array ={7,7,3,0,0,0};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testFlush() {
		Hand hand = new Hand();
        hand.addCard(new Card(Card.CardRankEnum.SEVEN,Card.CardSuitEnum.SPADES));
        hand.addCard(new Card(Card.CardRankEnum.THREE,Card.CardSuitEnum.SPADES));
        hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.SPADES));
        hand.addCard(new Card(Card.CardRankEnum.NINE,Card.CardSuitEnum.SPADES));
        hand.addCard(new Card(Card.CardRankEnum.QUEEN,Card.CardSuitEnum.SPADES));
        int [] array ={6,12,9,7,5,3};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testStraight() {
		 Hand hand = new Hand();
         hand.addCard(new Card(Card.CardRankEnum.SEVEN,Card.CardSuitEnum.SPADES));
         hand.addCard(new Card(Card.CardRankEnum.SIX,Card.CardSuitEnum.HEARTS));
         hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.SPADES));
         hand.addCard(new Card(Card.CardRankEnum.THREE,Card.CardSuitEnum.DIAMONDS));
         hand.addCard(new Card(Card.CardRankEnum.FOUR,Card.CardSuitEnum.SPADES));
        int [] array ={5,7,6,5,4,3};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testStraightWithAce() {
	       Hand hand = new Hand();
           hand.addCard(new Card(Card.CardRankEnum.ACE,Card.CardSuitEnum.SPADES));
           hand.addCard(new Card(Card.CardRankEnum.DEUCE,Card.CardSuitEnum.HEARTS));
           hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.SPADES));
           hand.addCard(new Card(Card.CardRankEnum.THREE,Card.CardSuitEnum.DIAMONDS));
           hand.addCard(new Card(Card.CardRankEnum.FOUR,Card.CardSuitEnum.SPADES));
        int [] array ={5,5,4,3,2,1};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testTriple() {
		 Hand hand = new Hand();
         hand.addCard(new Card(Card.CardRankEnum.ACE,Card.CardSuitEnum.SPADES));
         hand.addCard(new Card(Card.CardRankEnum.ACE,Card.CardSuitEnum.HEARTS));
         hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.SPADES));
         hand.addCard(new Card(Card.CardRankEnum.ACE,Card.CardSuitEnum.DIAMONDS));
         hand.addCard(new Card(Card.CardRankEnum.FOUR,Card.CardSuitEnum.SPADES));
        int [] array ={4,14,5,4,0,0};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testTwoPair() {
		  Hand hand = new Hand();
          hand.addCard(new Card(Card.CardRankEnum.ACE,Card.CardSuitEnum.SPADES));
          hand.addCard(new Card(Card.CardRankEnum.ACE,Card.CardSuitEnum.HEARTS));
          hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.SPADES));
          hand.addCard(new Card(Card.CardRankEnum.FIVE,Card.CardSuitEnum.DIAMONDS));
          hand.addCard(new Card(Card.CardRankEnum.SEVEN,Card.CardSuitEnum.SPADES));
        int [] array ={3,14,5,7,0,0};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testHighCard() {
		Hand hand = new Hand();
        hand.addCard(new Card(Card.CardRankEnum.DEUCE,Card.CardSuitEnum.SPADES));
        hand.addCard(new Card(Card.CardRankEnum.TEN,Card.CardSuitEnum.HEARTS));
        hand.addCard(new Card(Card.CardRankEnum.THREE,Card.CardSuitEnum.SPADES));
        hand.addCard(new Card(Card.CardRankEnum.QUEEN,Card.CardSuitEnum.DIAMONDS));
        hand.addCard(new Card(Card.CardRankEnum.JACK,Card.CardSuitEnum.SPADES));
        int [] array ={1,12,11,10,3,2};
        assertArrayEquals(array, hand.determineHandRanking());
	}
	
	@Test
	public void testCardCount() {
		Hand hand = new Hand();
        hand.addCard(new Card(Card.CardRankEnum.DEUCE,Card.CardSuitEnum.SPADES));
        hand.addCard(new Card(Card.CardRankEnum.TEN,Card.CardSuitEnum.HEARTS));
        assertEquals(hand.getCardCount(),2);
	}
	
	@Test
	public void testHandRest() {
		Hand hand = new Hand();
        hand.addCard(new Card(Card.CardRankEnum.DEUCE,Card.CardSuitEnum.SPADES));
        hand.addCard(new Card(Card.CardRankEnum.TEN,Card.CardSuitEnum.HEARTS));
        hand.reset();
        assertEquals(hand.getCardCount(),0);
	}
}

